<template>
  <div class="outer">
    <div
      class="topcard"
      v-for="item of cardlists"
      :key="item.n"
      @click="todetail(item.title)"
    >
      <div class="num" :class="{ topcolor: item.n in [1, 2, 3, 4] }">
        {{ item.n }}
      </div>
      <div class="cardavatar">
        <img v-lazy="item.imgUrl" alt="" />
      </div>
      <div class="carddesc">
        <div class="cardtitle">{{ item.title }}</div>
        <div class="cardscore">
          <span class="iconfont icon-defen"></span> {{ item.score }}
          <span class="spand">{{ item.spand }}</span>
        </div>
        <div class="cardtag">
          <div class="stag" v-for="(t, index) of item.tag" :key="index">
            {{ t }}
          </div>
        </div>
      </div>
      <div class="cardbtn">详情</div>
    </div>
  </div>
</template>
<script>
export default {
  name: "TopCard",
  props: {
    cardlists: Array,
  },
  methods: {
    todetail(title) {
      this.$router.push({
        path: "detail",
        query: {
          gameName: title,
        },
      });
    },
  },
  data() {
    return {};
  },
};
</script>
<style lang="scss" scoped>
.topcolor {
  color: red;
}
.topcard {
  display: flex;
  align-items: center;
  background: white;
  height: 1.4676rem;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
  .num {
  }
  .cardavatar img {
    width: 1.024rem;
    margin-left: 0.2rem;
  }
  .carddesc {
    margin-right: auto;
    margin-left: 0.2rem;
    .cardtitle {
      font-size: 0.28rem;
    }
    .cardscore {
      color: $themeColor;
      margin: 0.1rem 0 0 -0.02rem;
      line-height: 1.5em;
      font-size: 0.24rem;
      .spand {
        color: $fontGrayColor;
      }
    }
    .cardtag .stag {
      font-size: 0.24rem;
      color: $fontGrayColor;
      border: 0.02rem #ddd solid;
      display: inline-block;
      padding: 0 0.08rem;
      margin-left: 0.1rem;
    }
    .cardtag .stag:nth-child(1) {
      margin-left: 0;
    }
  }
  .cardbtn {
    background: $themeColor;
    color: white;
    padding: 0.16rem 0.2rem;
    border-radius: 12%;
  }
}
</style>